<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@page import="java.io.File"%>
<%@page import="BusinessLogic.Result.ResultType"%>
<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Map" %>
<%@ page import="BusinessLogic.Result" %>
<%@ page import="BusinessLogic.User" %>
<%@ page import="BusinessLogic.UserManager.Fields" %>
<%@ page import="BusinessLogic.Course" %>
<link href="public/style.css" rel="stylesheet" type="text/css" media="screen"/>
<title>Insert title here</title>
<jsp:useBean id="requestHandler" class="RequestHandlerPackage.RequestHandler" scope="application"/>
<%
String uName = request.getUserPrincipal().getName();
Map<String, String[]> params = new HashMap<String,String[]>();
params.put("action",new String[]{"getUser"});
params.put("USER_NAME",new String[]{uName});
params.put("me",new String[]{uName});
Result res = requestHandler.handle(params);
if (res.getResultType().equals(ResultType.FAILURE)){
  	String loginUrl = request.getContextPath()+"/";	
    session.invalidate();
}else if (((User)(res.getSuccessReturnValue())).getRole().equals("admin")){
  	String adminUrl = request.getContextPath()+"/admin";
	response.sendRedirect(adminUrl);
}
%>
</head>
	<body>
	    <div id="page">
	        <div id="header">
	            <h1><a href="./">Easy<span class="logo">Schedule</span></a></h1>
	            <p id="subtitle">Nice and easy registration system</p>
	        </div>
	        <div id="menu">
	            <ul>
	                <li class="left_menu"><a href="./">Home</a></li>
	                <li class="left_menu"><a href="./about.html">About</a></li>
	                <li class="left_menu"><a href="/tamirandevyatar/logout">Logout</a></li>
	            </ul>
	        </div>
	        <div id="main">	
	            <div id="sidebar">
	                 <div class="box" id="sidebar_head">
	                    <h2><a id="loginAnchor">User</a></h2>
	                    <div class="box2">
                        <ul>
                            <li><a href="/tamirandevyatar/allCourses">Show courses</a></li>
                            <li><a href="/tamirandevyatar/search">Search courses</a></li>
                            <li><a href="/tamirandevyatar/timetable">My timetable</a></li>
                            <li><a href="/tamirandevyatar/update">Update my details</a></li>
                            <li><a href="/tamirandevyatar/users">View users</a></li>
                            
                        </ul>
                        </div>
	                </div>			
	            </div><!-- sidebar -->    	              
	            <div id="content">
	                <div id="contheader">
	                    <h2>Welcome!</h2>
	                </div>		
	                <div id="content2" class="welcome">	
						<h2>Welcome To EasySchedule</h2>
						<div class="entry">
							<p>EasySchedule is a convenient and intuitive system that lets you plan your semester schedule.</p>
							<p>On EasySchedule you will be able to view your timetable, search for courses that interest you, and register to those courses.</p>
						</div>
	                </div><!-- content2 -->								              
	            </div><!-- content -->                    
	            <div class="clearing">&nbsp;</div> 
	            <div id="footer">
	                <p><a href="http://www.cs.technion.ac.il/~cs236369/">Managing Data on the World-Wide Web</a></p>
	            </div>
	        </div><!-- main -->
	    </div><!-- page -->

	</body>
</html>